package com.lyluly.coursemgmt.servicemodule.iService.serviceImpl;

import com.lyluly.coursemgmt.servicemodule.iDao.WechatPushMapper;
import com.lyluly.coursemgmt.servicemodule.iService.IWechatPushService;
import com.lyluly.coursemgmt.servicemodule.model.WechatPush;
import com.lyluly.coursemgmt.servicemodule.model.WechatPushExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class WechatPushServiceImpl implements IWechatPushService {
    @Autowired
    private WechatPushMapper wechatPushMapper;

    public void addWechatPush(WechatPush wechatPush) {
        wechatPush.setCreatetime(new Date());
        wechatPushMapper.insert(wechatPush);
    }

    public void modifyWechatPush(WechatPush wechatPush) {
        wechatPushMapper.updateByPrimaryKeySelective(wechatPush);
    }

    public void removeWechatPush(int pushId) {
        wechatPushMapper.deleteByPrimaryKey(pushId);
    }

    public WechatPush findWechatPushById(int pushId) {
        return wechatPushMapper.selectByPrimaryKey(pushId);
    }

    public List<WechatPush> findWechatPushList() {
        return wechatPushMapper.selectByExample(null);
    }

    public List<WechatPush> findWechatPushListByPushClass(String clazz) {
        WechatPushExample wechatPushExample = new WechatPushExample();
        wechatPushExample.or().andPushClassEqualTo(clazz);
        return wechatPushMapper.selectByExample(wechatPushExample);
    }
}
